Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

248
Vistas
Get JavaScript event "focusout"-direction?

I have a listt like

<ul>
    <li class="first"></li>
    <li></li>
    <li></li>
    <li></li>
    <li class="last"></li>
</ul>

Now if one uses the tab-key to move over this list, after the last item, the focus jumps to a specific point on the page. No Problem so far:

// using the 'focusout' eventListener:
if (event.target.classList.contains('last')) {
    document.querySelector('#go-here-after-last').focus();
}

Now, I need to achieve the same thing but in the other direction. I move the focus with SHIFT+TAB a stepping backward, and I hit the item with class "first".

Now focusout triggers everytime - but i need only the "focus out is triggered while going reverse"

looking into the event shows a event.relatedTarget, that seems to be the originally next target, but thats not safe to use in my case.

Is there a way to achieve something like a "reverse-focus-detection"?

Thank you

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda